package com.akk.module.avs.service;

import com.akk.module.avs.entity.AvsAccess;
import com.akk.module.avs.entity.AvsAccessExample;
import com.akk.module.avs.mapper.AvsAccessMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class AvsAccessService {
    @Autowired
    AvsAccessMapper accessMapper;
    @Autowired
    AvsAccessExample accessExample;

    public List<AvsAccess> findByParam(Map param) {
        accessExample.clear();
        AvsAccessExample.Criteria criteria = accessExample.createCriteria();
        if(param.containsKey("accessName")){
            criteria.andAccessNameLike(param.get("accessName").toString());
        }
        return accessMapper.selectByExample(accessExample);
    }

    public AvsAccess findById(String id){
        return accessMapper.selectByPrimaryKey(id);
    }

    public void saveAccess(AvsAccess access) {
        accessMapper.insert(access);
    }

    public void updateAccess(AvsAccess access) {
        accessMapper.updateByPrimaryKey(access);
    }
}
